package com.wang.pages;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.internal.services.StringValueEncoder;

public class InputCore {
	@Property
	@SuppressWarnings("unused")
	private StringValueEncoder stringEncoder = new StringValueEncoder();
	 
	/* Checkbox */
	 
	@Property
	@Persist
	@SuppressWarnings("unused")
	private boolean checkboxValue;
	 
	/* Checklist */
	 
	@Property
	@Persist
	@SuppressWarnings("unused")
	private List<String> checklistSelectedValues;
	 
	@Property
	@SuppressWarnings("unused")
	private final String[] STATIONERY = { "Pens", "Pencils", "Paper" };
	 
	/* DateField */
	 
	@Property
	@Persist
	private Date dateValue;
	 
	// We could return a DateFormat, but instead we'll return a String which DateField will coerce into a DateFormat.
	public String getDateFieldFormat() {
	return "dd/MM/yyyy";
	}
	 
	/* Palette */
	 
	@Property
	@Persist
	private List<String> paletteSelectedValues;
	 
	@Property
	@SuppressWarnings("unused")
	private final String[] PETS = { "Dog", "Cat", "Parrot", "Mouse" };
	 
	/* Password */
	 
	@Property
	@Persist
	@SuppressWarnings("unused")
	private String passwordValue;
	 
	/* RadioGroup and Radio */
	 
	@Property
	@Persist
	@SuppressWarnings("unused")
	private String radioSelectedValue;
	 
	/* Select */
	 
	@Property
	@Persist
	@SuppressWarnings("unused")
	private String selectedValue;
	 
	/* TextArea */
	 
	@Property
	@Persist
	@SuppressWarnings("unused")
	private String textAreaValue;
	 
	/* TextField */
	 
	@Property
	@Persist
	@SuppressWarnings("unused")
	private String textValue;
	 
	/* Life-cycle stuff. Fields that are marked @Persist MUST be initialized here rather than where they are declared. */
	 
	void setupRender() {
	if (dateValue == null) {
	dateValue = new Date();
	}
	if (paletteSelectedValues == null) {
	paletteSelectedValues = new ArrayList<String>();
	}
	}
}
